import { baseRequestClient, requestClient } from '#/api/request';

export namespace RtSales {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    remark: string;
    params: Params;
    rtId: number;
    rtCode: string;
    rtName: string;
    soCode: string;
    clientId: number;
    clientCode: string;
    clientName: string;
    clientNick: null;
    rtDate: Date;
    rtReason: string;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getRtSalesTableList = (params: RtSales.GetListParams) =>
  requestClient.get<RtSales.GetListReturn>('/mes/wm/rtsales/list', {
    params,
  });
// 增加销售退货单
export const addRtSales = (data: RtSales.Row) =>
  requestClient.post<RtSales.GetListReturn>('/mes/wm/rtsales', data);

// 删除销售退货单
export const deleteRtSales = (id: string) =>
  requestClient.delete<RtSales.GetListReturn>(`/mes/wm/rtsales/${id}`);

// 修改销售退货单
export const updateRtSales = (data: RtSales.Row) =>
  requestClient.put<RtSales.GetListReturn>('/mes/wm/rtsales', data);

export const getRtSalesCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/PRODUCTSALSE_CODE');
